package heima;
//规范1.private成员变量2.getset方法3.无惨构造函数4.满参构造函数5.this.成员变量带上6.形参与成员变量名字一致
//构造方法创建一次对象执行一次
//javabean
public class Zhigong {
    private String name;
    private int age;

    public Zhigong(String name, int age) {
        this.name = name;
        this.age = age;
    }
    //默认无惨构造函数,若是有其它构造函数,则没有默认的构造函数
    public Zhigong() {
        super();
        System.out.println("this赋值前");
        System.out.println(this.age);
        this.age=100;
        System.out.println("this赋值后");
        System.out.println(this.age);
        return;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if(name.length()>8){
            System.out.println("你输入的姓名有误!");
        }else{
            this.name = name;
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age<=0||age>150){
            System.out.println("你输入的年龄有误!");
        }else{
            this.age = age;
        }
    }

    public Zhigong(String name) {
        this.name = name;
    }

    public Zhigong(int age) {
        this.age = age;
    }
}
